<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="jquery.js"></script>
</head>
<body>
    <button onclick="login()">测试登录</button>
    <button onclick="post('/postFilter')">测试请求</button>
</body>
</html>
<script>
    let jwtKey = "";
    let auth = "auth";

    function login(){
        $.ajax({
            url:"/login",
            type: "POST",
            data: {username: 'admin', password: '123'},
            success:function(data){
                jwtKey = data;
                alert("登录成功");
            }
        })
    }

    function post(url){
        $.ajax({
            url:url,
            type: "POST",
            beforeSend: function (XMLHttpRequest) {
                XMLHttpRequest.setRequestHeader(auth, jwtKey);
            },
            dataType:"json",
            success:function(data){
                console.log(data);
            }
        })
    }
</script>